package com.rd.student.jiaji.class3.qinjialin.day0728;

import java.io.BufferedReader;
import java.io.FileReader;
import java.util.*;

public class Quesitions2 {

    public static void main(String[] args) throws Exception {
        System.out.println("请输入一个数字：");
        Scanner scanner = new Scanner(System.in);
        ArrayList names = new ArrayList();

        try (Scanner sc = new Scanner(new FileReader("all.txt"))) {
            sc.useDelimiter("、");
            while (sc.hasNext()) {
                String str = sc.next();
                names.add(str);
            }
        }


        Set<String> selectedNames = new HashSet<>();
        int n = scanner.nextInt();
        while (selectedNames.size() < n) {
            Random random = new Random();
            int i = random.nextInt(names.size());
            selectedNames.add((String) names.get(i));
        }

        System.out.println("随机生成的人名：");
        for (String name : selectedNames) {
            System.out.println(name);

        }
    }
}